home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 42
/
Amiga Format AFCD42 (Issue 126, Aug 1999).iso
/
-coverdisks-
/
126a
/
football
/
user
/
updateschedulescores.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1999-05-22
|
13KB
|
456 lines
/* ***********************************************************************
UPDATE SCHEDULE FILE PROGRAM FOR FOOTBALL REXX SUITE
----------------------------------------------------
Copyright Mark Naughton 1998
Version Date History
--------------------------------------------------------------------------
1.0 011098 Created. Found problem where the updates are not
successfully made - fixed. Updated messages.
1.1 050599 Added code to check the schedule file to see if it
contains the right number of matches for the number of
teams playing a specified number of times. Added
support for playing an odd number of times and for
schedules for teams playing more than twice.
**************************************************************************
Procedure
---------
1. Check files exist. Get schedule definition filename from '.df' file.
2. Read specified schedule definition file. Check schedule contains the
right number of matches before proceeding.
3. Read schedules and store dates/weeks.
4. Give error if the number of teams does not equal the number of lines in
the schedule file.
5. Write the dates/weeks to a file then use an external program to sort
them, writing back to the file.
6. Read dates into array and delete file.
7. Format dates array with season start date.
8. Format and write '.sf' files.
9. Read all data from Learn (without '*') into an array. Close file.
10.Open Schedule file and read into an array. Close file.
11.Update Schedule array with data from Learn but only if a match hasn't
been played.
12.Write to Schedule file. Close file. Exit.
************************************************************************** */
PARSE ARG league_file
version = 1
league_file = "Data/" || strip(league_file)
input_file = '.df'
input2_file = '.schd'
input3_file = '.sflearn'
output_file = '.sf'
title = '*LEAGUE_NAME='
autosched = "*AUTOSCHD="
playother = '*PLAY_OTHER='
teams. = '???'
dateweeks. = '???'
tdateweeks. = '???'
schedules2. = '???'
schedules4. = '???'
schedules6. = '???'
schedules8. = '???'
schedules0. = '???'
selines. = '???'
sdlines. = '???'
autos = 0
tcount = 0
ttc = 0
separator = '*'
not_played = '__ __'
months = "January February March April May June July August September October November December"
if exists(league_file || input_file) = 0 then exit
tcount = 0
if open(datafile,league_file || input_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
line = strip(line)
if pos(separator,line) > 0 then do
if pos(autosched,line) > 0 then do
autofile = delstr(line,1,10)
autos = 1
end
if pos(title,line) > 0 then do
parse var line "*LEAGUE_NAME=" league_title
league_title = strip(league_title)
end
if pos(playother,line) > 0 then
playo = delstr(line,1,12)
end
if pos(separator,line) = 0 & line ~="" then do
tcount = tcount + 1
teams.tcount = line
end
end
close(datafile)
end
else do
say
say "ERROR : (UpdateScheduleScores)"
say
say "Cannot open '"league_file || input_file"' for reading."
exit
end
/* Automatic Schedule creation */
if autos = 1 then do
if exists("Data/"autofile||input2_file) = 0 then do
say
say "ERROR : (UpdateScheduleScores)"
say
say "Cannot find 'Data/"autofile||input2_file"'."
exit
end
ct = 0
sct2= 0
sct4= 0
sct6= 0
sct8= 0
sct0= 0
weeks = 0
dates = 0
sch = 1
if open(datafile,"Data/"autofile||input2_file,'r') then do
mkct = ((tcount - 1) * playo) * (tcount/2)
kmct = 0
do while ~eof(datafile)
line = readln(datafile)
if line ~= '' & pos(separator,line) = 0 then do
counter = words(line)
do i=1 to counter
if word(line,i) ~= 0 then
kmct = kmct + 1
end
end
end
close(datafile)
end
else do
say
say "ERROR : (UpdateScheduleScores)"
say
say "Cannot find 'Data/"autofile||input2_file"' for reading."
say
say
say "The definition file, '"league_file || input_file"' has been created."
exit
end
if mkct ~= kmct then do
say
say "ERROR : (UpdateScheduleScores)"
say
say "UpdateScheduleScores has found that the schedule file 'Data/"autofile||input2_file"'"
say "does not contain the correct number matches for "tcount" teams to play each other"
say playo" times. It contains "kmct" matches, where as it should contain "mkct" matches."
say "You will have to edit the schedule file or change the settings required when"
say "recreating the league or before running this program again."
exit
end
if open(datafile,"Data/"autofile||input2_file,'r') then do
do while ~eof(datafile)
line = readln(datafile)
if pos("*WEEKS",line) then do
weeks=1
end
if pos("*DATES=",line) then do
startdate=substr(line,8,8)
dates = 1
end
if pos("*NEXT",line) > 0 then sch = sch + 1
if line ~= '' & pos(separator,line) = 0 then do
if sch = 1 then do
sct2 = sct2 + 1
schedules2.sct2 = line
end
if sch = 2 then do
sct4 = sct4 + 1
schedules4.sct4 = line
end
if sch = 3 then do
sct6 = sct6 + 1
schedules6.sct6 = line
end
if sch = 4 then do
sct8 = sct8 + 1
schedules8.sct8 = line
end
if sch = 5 then do
sct0 = sct0 + 1
schedules0.sct0 = line
end
counter = words(line)
do i=1 to counter
sdate = word(line,i)
if sdate = 0 then
iterate
if ct = 0 then do
ct = ct + 1
dateweeks.ct = sdate
end
else do
ij = 0
do j=1 to ct
if sdate = dateweeks.j then do
ij = 1
leave
end
end
if ij = 0 then do
ct = ct + 1
dateweeks.ct = sdate
end
end
end
end
end
close(datafile)
end
else do
say
say "ERROR : (UpdateScheduleScores)"
say
say "Cannot find 'Data/"autofile||input2_file"' for reading."
exit
end
sct = (sct2 + sct4 + sct6 + sct8 + sct0) / sch
if counter ~= sct then do
say
say "ERROR : (UpdateScheduleScores)"
say
say "The schedule definition file specified only has "sct" scheduled"
say "teams whereas there are "tcount" teams in the league."
say
say "Creation of files aborted. Re-specify correct schedule."
say
say "Definition file : "league_file||input_file
say "Schedule Def. file : Data/"autofile||input2_file
say
exit
end
if open(datafile2,"RAM:schd.temp",'w') then do
do j=1 to ct
writeln(datafile2,dateweeks.j)
end
close(datafile2)
end
else do
say
say "ERROR : (UpdateScheduleScores)"
say
say "Cannot create temporary file in RAM:."
exit
end
if weeks = 1 then
address command 'sort RAM:schd.temp RAM:schd.temp'
if dates = 1 then
address command 'Exec/SortWkDts'
if open(datafile2,"RAM:schd.temp",'r') then do
do j=1 to ct
dateweeks.j = readln(datafile2)
end
close(datafile2)
end
else do
say
say "ERROR : (UpdateScheduleScores)"
say
say "Cannot find te